Skip to content

Conversation

RalfJung
Copy link
Member

r? types or @oli-obk, you know best how deprecated this really is

Context: rust-lang/stdarch#1916

@rustbot
Copy link
Collaborator

rustbot commented Sep 15, 2025

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

stdarch is developed in its own repository. If possible, consider making this change to rust-lang/stdarch instead.

cc @Amanieu, @folkertdev, @sayantn

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 15, 2025
EncodeCrossCrate::No, ),
rustc_attr!(
rustc_legacy_const_generics, Normal, template!(List: &["N"]), ErrorFollowing,
rustc_deprecated_legacy_const_generics, Normal, template!(List: &["N"]), ErrorFollowing,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it'd be worth adding a comment here to the effect that this should not be newly applied anywhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt anyone who might be tempted to apply it would see a comment deep inside the rustc sources.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, just an hour ago I was thinking to name it legacy_const_generics_do_not_use just to avoid any and all ambiguity

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I considered that name but it seemed a bit too cheesy ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also considered rustc_legacy_const_generics_deprecated (instead of rustc_deprecated_legacy_const_generics), not sure which order makes more sense.

@rust-log-analyzer

This comment has been minimized.

@RalfJung RalfJung force-pushed the legacy-const-generic-deprecated branch from 895407f to 6646334 Compare September 15, 2025 09:33
@lcnr
Copy link
Contributor

lcnr commented Sep 15, 2025

r=me on the name change

legacy const generics arguments have weird restriction and I also really feel like if we actually want better support for const generics, that should be an actually stable feature instead of some widely used std internal hack

use std::arch::x86_64::_mm_aeskeygenassist_si128;
fn main() {
    _mm_aeskeygenassist_si128(return, {
        struct Foo;
        1
    });
}
error: invalid argument to a legacy const generic: cannot have const blocks, closures, async blocks or items
 --> src/main.rs:4:9
  |
4 |         struct Foo;
  |         ^^^^^^^^^^^
  |
help: try using a const generic argument instead
  |
3 ~     _mm_aeskeygenassist_si128::<{ {
4 +     struct Foo;
5 +     1
6 ~ } }>(return);
  |

I feel like ideally we have an explicit allow-list for all functions marked with that attribute and need people to add any new functions to it manually. Idk how much effort that is however.

@RalfJung
Copy link
Member Author

RalfJung commented Sep 15, 2025

I feel like ideally we have an explicit allow-list for all functions marked with that attribute and need people to add any new functions to it manually.

I don't think that's worth it, the compiler has to trust the standard library to not misuse the unstable features that exist solely to support the standard library. Ofc reviewers forget things so we should support them where we can, but an allowlist seems pretty heavy-handed.

IOW, the attribute is the allowlist.

@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member Author

Looks like there wasn't actually a team decision to deprecate this (rust-lang/stdarch#1916 (comment)), so let's hold off on this PR for now.

@RalfJung RalfJung added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Sep 15, 2025
@RalfJung RalfJung force-pushed the legacy-const-generic-deprecated branch from 6646334 to 760afcc Compare September 15, 2025 12:43
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [rustdoc] tests/rustdoc/constant/legacy-const-generic.rs stdout ----
------rustdoc stdout------------------------------

------rustdoc stderr------------------------------
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
##[error]  --> /checkout/tests/rustdoc/constant/legacy-const-generic.rs:13:3
   |
13 | #[rustc_legacy_const_generics(1, 2)]
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
##[error] --> /checkout/tests/rustdoc/constant/legacy-const-generic.rs:6:3
  |
6 | #[rustc_legacy_const_generics(1)]
  |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot find attribute `rustc_legacy_const_generics` in this scope
##[error]  --> /checkout/tests/rustdoc/constant/legacy-const-generic.rs:13:3
   |
13 | #[rustc_legacy_const_generics(1, 2)]
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot find attribute `rustc_legacy_const_generics` in this scope
##[error] --> /checkout/tests/rustdoc/constant/legacy-const-generic.rs:6:3
  |
---
------------------------------------------

error: rustdoc failed!
status: exit status: 1
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc/constant/legacy-const-generic" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc/constant/legacy-const-generic/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc/constant/legacy-const-generic" "--deny" "warnings" "/checkout/tests/rustdoc/constant/legacy-const-generic.rs" "-A" "internal_features"
stdout: none
--- stderr -------------------------------
error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
##[error]  --> /checkout/tests/rustdoc/constant/legacy-const-generic.rs:13:3
   |
13 | #[rustc_legacy_const_generics(1, 2)]
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
##[error] --> /checkout/tests/rustdoc/constant/legacy-const-generic.rs:6:3
  |
6 | #[rustc_legacy_const_generics(1)]
  |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot find attribute `rustc_legacy_const_generics` in this scope
##[error]  --> /checkout/tests/rustdoc/constant/legacy-const-generic.rs:13:3
   |
13 | #[rustc_legacy_const_generics(1, 2)]
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot find attribute `rustc_legacy_const_generics` in this scope
##[error] --> /checkout/tests/rustdoc/constant/legacy-const-generic.rs:6:3
  |

@traviscross
Copy link
Contributor

Nominated this question as part of:

@traviscross traviscross added I-lang-radar Items that are on lang's radar and will need eventual work or consideration. T-lang Relevant to the language team labels Sep 15, 2025
@lcnr lcnr removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 17, 2025
@bors
Copy link
Collaborator

bors commented Sep 19, 2025

☔ The latest upstream changes (presumably #146700) made this pull request unmergeable. Please resolve the merge conflicts.

@RalfJung RalfJung marked this pull request as draft September 24, 2025 20:40
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-blocked Status: Blocked on something else such as an RFC or other implementation work. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants